Advanced Renaming

Advanced Renaming topics include the following categories:

Swapping Fields

Swapping fields of a name can be done easily in the custom renaming panel with regular expressions. If for example you have filenames of the form:

artist - title - album.mp3

where the fields for artist, title, and album are separated by dashes and you want to change this to:

title - album - artist.mp3

What you have to do is isolate the fields into groups. Each group in a regex is surrounded by parentheses. In this case you would put the following into the search column:

(.*?)-(.*?)-(.*?).mp3

This pattern has three groups. Group 1 is the artist field, Group 2 is the title field, and group 3 is the album field. Group 1 matches any character up to the first dash character. The dash is not included in the group. Group 2 matches any characters between the first dash and second dash. Again the dashes are not included in the group. Group 3 matches any characters between the second dash and the .mp3. the second dash and the .mp3 are not included in the group.

In the replace column you identify group 1 (artist) as \1, group 2 (title) as \2, and group 3 (album) as \3. If you wanted the new name to be of the form: title - album - artist

then you would specify:

\2 - \3 - \1.mp3

You will probably end up with extra whitespace around the dashes but that can be cleaned up by putting a "Delete All Extra Whitespace in Prefix" command into the next row.

Creating Folder Paths from Names

Creating a hierarchy of folder paths from parts of a name can be done easily in the custom renaming panel with regular expressions. You have to use the BUILD PATH regular expression PFrank extension flag (see Regex Flags section). If for example you have the following filenames:

Report1 123-00.xls
Report1 123-01.xls
Report1 123-02.xls
Report1 123-03.xls
Report2 212-00.xls
Report2 212-01.xls
Report2 212-02.xls
Report2 212-03.xls
Report3 215-00.xls
Report3 215-01.xls
Report3 215-02.xls
Report3 215-03.xls

And you would like to put them in a folder structure like this:

/MyReport1
        /123
            /00.xls
            /01.xls
            /02.xls
            /03.xls
/MyReport2
        /212
            /00.xls
            /01.xls
            /02.xls
            /03.xls
/MyReport3
        /215
            /00.xls
            /01.xls
            /02.xls
            /03.xls

This is what you do. In the search column identify the different groups by entering this:

(Report[0-9]+?) ([0-9]+?)-([0-9]+?.xls)

There are 3 sets of parentheses identifying the 3 different groups. Next you prefix the pattern with a regex flag. The flag used is 'B' which is a special PFrank extension. Thus you now have:

(?B)(Report[0-9]+?) ([0-9]+?)-([0-9]+?).xls

The flag modifies the illegal character checking in the replacement pattern so that the forward slash character is allowed. In the replace column you would specify:

My\1/\2/\3

The forward slashes identify where the folder boundaries are. When you carry out the renaming, a folder identified by group 1 will be created in the current folder, a folder identified by group 2 will be created under the group 1 folder, and a filename identified by group 3 will be created under the group 2 folder.
e.g. Report3 215-03.xls will be converted to MyReport3\215\03.xls where the Report3 folder will be created under the current folder.

This feature is automatically disabled when SubVersion (SVN) mode is enabled.

Add Meta Data and Counters

Below is an example custom sequence for Adding date/time and picture size information to a set of photo files. The file names are:

IMG_0014.jpg
IMG_0016.jpg
IMG_0017.jpg
IMG_0022.jpg
IMG_0031.jpg
You would like to change the names to the following form:
     Vacation_<counter>_<Date> size(<height>x<width>).jpg

An example is below:

Vacation_0001_(Sunday January 01,2006) size(1983x2754).jpg
Vacation_0001_(Sunday January 01,2006) size(2208x3071).jpg
Vacation_0001_(Sunday January 01,2006) size(2698x2300).jpg
Vacation_0001_(Sunday January 02,2006) size(1983x2754).jpg
Vacation_0001_(Sunday January 02,2006) size(2698x2300).jpg
Vacation_0001_(Sunday January 02,2006) size(2208x3071).jpg
This can be done using the custom renaming as follows:
Row: 1
   Search:  'IMG_[0-9]+'
   Replace: ''
Row: 2
   Search:  '.jpg'
   Replace: 'Vacation.jpg'
Row: 3
   Search:  ''
   Replace: '*Insert Counter after*Prefix*'
Row: 4
   Search:  ''
   Replace: '*Insert Image Information after*Prefix*'
       Custom Format String for Insertion:
            '(%DateTime%) size(%Width%x%Height%)'
The first row strips everything away except the extension.
The second row adds the word 'Vacation' before the extension
The third row adds a counter after the word 'Vacation'
The fourth row adds date/time, height, and width meta data. The date time format is configured using the 'Data Formatter' on the options window.

Create Your Own Renaming Commands

You can create your own renaming commands that when loaded, will appear at the end of the pre-defined command list of the main window. Details of how to load the commands are explained in the User Command Panel section. Sample commands and Details of the Python-based programming API are in the PFrankUser.py.template file found in the PFrank install folder.

Post Processing Renaming

Some users deliberately use the duplicate renaming resolver to add resolving strings to their names but the resolving names are not exactly what they want. With the post processsing feature, you can configure some renaming to be done after the duplicate name resolution phase. Post processing can ony be used with regular expressions in the custom renaming list. This is accomplished by using the POST PROCESSING regular expression PFrank extension flag (see Regex Flags section).

An example is shown below (it is assumed that the duplication resolver is configiured to add a counter after the name prefix):

Row: 1
   Search:  '.*\.jpg'
   Replace: 'Photo # Vacation.jpg'
Row: 2
   Search:  '(?Z)(.{7,7})(.*?)([0-9]+.)jpg'
   Replace: '\1\3\2.jpg'

Row 1 will produce many duplicates which will be resolved by PFrank by adding a number at the end of the prefix. Row 2 is executed after the duplicate name resolver as part of the post processing phase. The post processing takes the number that was added at the end of the name prefix, and moves it after the # character in the prefix. Note that another phase of name duplication resolution will take place after the post processing in case there are still duplicate names.